package thread.test3Volatile;

import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 */
public class VolatileTest3 {
    public AtomicInteger a=new AtomicInteger();

    public void increase() {
        a.incrementAndGet();
    }

    /**
     *
     *
     */
    public static void main(String[] args) {
        final VolatileTest3 test = new VolatileTest3();
        for(int i=0;i<10;i++){
            new Thread(){
                public void run() {
                    for(int j=0;j<1000;j++)
                        test.increase();
                };
            }.start();
        }

        while(Thread.activeCount()>1)
            Thread.yield();
        System.out.println(test.a.get());
    }
}
